1. Field of the Invention
The present invention relates to methods for compressing and expanding multiple gradation image for use in a printer, a copying machine or the like.
2. Description of the Related Art
In recent years, office machines such as printers and copiers have become increasingly prevalent not only in various types of offices but also in personal use. Further, such apparatuses are required to be capable of handling a high quality of image or color image. The color image, in particular, which is enormous in its data quantity, has inevitably required an increased memory capacity and an associated disadvantageous price increase. Realization of a low price requires image data to be compressed while keeping its high quality so that the memory capacity necessary for storage of the image can be decreased.
Conventional methods for compressing information on a gradation image include a technique called block coding, which will be explained by referring to FIGS. 1 to 5.
FIG. 1 shows an enlargement of a part of an image. In FIG. 1, reference numeral 2 denotes a pixel which is a minimum unit of the image. It is assumed that one pixel 2 is represented by 8 bit data and handles 256 gradations having values of 0 to 255. A block 3 is a 4.times.4 array of adjacent pixels 2 (a total of 16 pixels), and processing is carried out on a block basis.
FIG. 2 shows an actual example of the block 3, and FIG. 3 shows a procedure of subjecting the block 3 to the block coding.
First of all, an average value of the values of the pixels in the block 3 to be subjected to the block coding is calculated, and the average value is used as an in-block average value m (step 1). The in-block average value m in the block 3 as shown in FIG. 2 is 122 when the values of the pixels are rounded off to the nearest integer.
Next, the in-block average value is compared with the values of the pixels in the block 3 so that the pixels having values less than the in-block average value are represented by "0", while the pixels not less than the in-block average value are represented by "1" to thereby form a pixel array pattern (step 2). The pixel array pattern corresponding to the block 3 of FIG. 2 is shown in FIG. 4.
An average value a0 of the values of the pixels belonging to a group of the pixel represented by "0" in the pixel array pattern as well as an average value a1 of the values of the pixels belonging to a group of the pixel represented by "1" therein are calculated to be used as block representative values respectively (step 3). In the case of the block 3 of FIG. 2, the block representative values a0 and a1 are 34 (22h) and 162 (A2h) respectively. A final block code 1 for the block 3 is made up of the two representative values, each consisting of 8 bit data, and a single pixel array pattern (bit map) of 16 bits as shown in FIG. 5A, which details are shown in FIG. 5B.
The expanding operation of restoring or reconstructing the block code 1 to actual image data will be explained in connection with FIG. 6. The block representative value a0 contained in the block code 1 of FIGS. 5A or 5B is applied to the pixels represented by "0" in the pixel array pattern; whereas the block representative value a1 contained in the block code 1 is applied to the pixels represented by "1" in the pixel array pattern. This operation is carried out for all the pixels of one block. An expanded image corresponding to the block code 1 of FIGS. 5A or 5B is shown in FIG. 7.
In general, when one pixel comprises q bits and the number of pixels in one block is denoted by N, the quantity of data in one block of an original image is (q.times.N) bits and the quantity of image data after subjecting the data to block coding is (2q+N) bits corresponding to a sum of the N bits of the pixel array pattern and (2.times.q) bits of block representative values. Accordingly, a compression ratio is qN/(2q+N), which becomes 4 in the case where the number q of bits of one pixel is 8 and the number of pixels of one block is 16 in the example of FIG. 5B.
When images are roughly separated into two types, the images are divided into such artificial images as made up of characters or graphics and such natural images as photographs or paintings. The artificial image includes a uniform portion in which most data have values equal to the values of in-block data. When the gradation varies, an amount of the variation is large. On the other hand, in the natural images, a variation in gradation between adjacent pixels always takes place but is small in most cases.
Meanwhile, in the prior art block coding, a compressed code for one block is represented always by two representative values and a single bit map, so that, even when the data in one block are all equal, that is, in the case of the artificial images, similar coding compression is carried out. Thus, even a block which can be sufficiently represented by a single representative value has two representative values, and even for an image having a small gradation variation the representative values are subjected to similar coding, which disadvantageously results in a law compression efficiency.